/*************************************************************************
> File Name: 03_test.cpp
> Author: hzy
> Created Time: 2023-08-16 17:11:58
> Description: 派生类为类模板
************************************************************************/
#include <iostream>

using namespace std;

template <class T>
class Base
{
private:
    T Val;

public:
    Base(T myVal) : Val(myVal) {}

    void setVal(T myVal)
    {
        Val = myVal;
    }

    T getVal()
    {
        return Val;
    }
};

template <class T>
class Son1 : public Base<T>
{
public:
    Son1(T myVal) : Base<T>(myVal) {}
};

template <class T, class U>
class Son2 : public Base<T>
{
private:
    U data;

public:
    Son2(T myVal, U myData) : Base<T>(myVal)
    {
        data = myData;
    }

    U getData()
    {
        return data;
    }
};

void test_01()
{
    Son1<int> son1(6);
    cout << son1.getVal() << endl;
}

void test_02()
{
    Son2<string, int> son2("wjy", 22);
    cout << son2.getVal() << "|" << son2.getData() << endl;
}

int main()
{
    test_01();
    test_02();

    return 0;
}